/*
 * FT6236.c
 *
 *  Created on: Apr 29, 2025
 *      Author: 17438
 */

#include "FT6236.h"

void FT6236_Init(void){
	;
}



//检测屏幕触摸事件
void FT6236_GetTouch(FT6236_Touch_TypeDef* pFT6236_Touch_Structure){
	uint8_t Data[6];
	HAL_I2C_Mem_Read(&hi2c1, FT6236_ADDR, 0x03, 1, Data, 6, 100);

	switch(Data[0] & 0xC0){
		case 0x00:{pFT6236_Touch_Structure -> Event = FT6236_Touch_Event_Press; break;}
		case 0x40:{pFT6236_Touch_Structure -> Event = FT6236_Touch_Event_Lift; break;}
		case 0x80:{pFT6236_Touch_Structure -> Event = FT6236_Touch_Event_Contect; break;}
		case 0xC0:{pFT6236_Touch_Structure -> Event = FT6236_Touch_Event_None; break;
	}
}

	pFT6236_Touch_Structure -> FT6236_Touch_X = 0x0000	| ((((uint16_t)Data[0]) & 0x0F) << 8)
														| ((uint16_t)Data[1]);
	pFT6236_Touch_Structure -> FT6236_Touch_Y = 0x0000	| ((((uint16_t)Data[2]) & 0x0F) << 8)
														| ((uint16_t)Data[3]);
	pFT6236_Touch_Structure -> FT6236_Touch_Force = Data[4];
	pFT6236_Touch_Structure -> FT6236_Touch_Size = Data[5];

}
